package all_in_one;

import java.util.concurrent.Semaphore;

public class Manny extends Thread implements ISmoker {

	private CigarettePlace m_place;
	private Semaphore m_sema = new Semaphore(1);
	public Manny(CigarettePlace cigarettePlace) {
		m_sema.drainPermits();
		m_place = cigarettePlace;
	}
	
	@Override
	public void run() {
		while(true)
		{
			m_place.GetSemaphoreArray().get(2).acquireUninterruptibly();
			System.out.println("Manny started smoking");
			m_place.GetCounter().Reset();
			m_sema.release();
		}
	}
	
	public synchronized Semaphore GetSemaphore()
	{
		return m_sema;
	}

}
